# -*- coding: utf-8 -*-

import os
import io
import re

fo = open("word.txt", "w")

result=set()
# 遍历指定目录，显示目录下的所有文件名
def each_file(filepath):
  for root, dirs, files in os.walk(filepath):
    for file in files:
      filename = os.path.join(root, file)
      read_file1(filename)

def read_file(filename):
  with io.open(filename, 'r', encoding='utf-8', errors='ignore') as fn:
  # with io.open(filename, 'r', encoding='gbk', errors='ignore') as fn:
    lines = fn.readlines()
    for num in lines:
      # print(num)
      x = num.split("：")
      # print(x[0])
      result.add(x[0])



def read_file1(filename):
  with io.open(filename, 'r', encoding='utf-8', errors='ignore') as fn:
    lines = fn.readlines()
    res1 = ''.join(re.findall('[\u4e00-\u9fa5]', str(lines)))
    # res2 = re.findall('[\u4e00-\u9fa5]', str(lines))
    print(res1)
    fo.write(res1 + "\n")

if __name__ == '__main__':
  # each_file("src")
  each_file(r"E:\青羊区项目\青羊区数据问题/")
  # read_file(r"E:\青羊区项目\青羊区数据问题\1-500导入建模错误信息.txt")
  print(result)
  print("完成")
